<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
error_reporting (E_ALL);
define ('DIR', DIRECTORY_SEPARATOR) ;
session_start() ;
$sitePath = realpath(dirname(__FILE__) . DIR . '..' . DIR) . DIR ;
define ('SITEPATH', $sitePath) ;

require_once 'includs/startup.php' ;
$registry = new Access_Registry ;

$template = new Access_Template($registry) ;
$registry->set ('view', $template) ;
require_once 'app/access/db.php' ;

$db = new Access_Db ;

$router = new Access_Router($registry);

$registry->set('sitePath', DIR . $db->path) ; 

$registry->set ('router', $router);

$registry->set('controllersPath', 'app/controller') ;

$router->setPath ($registry->get('controllersPath')) ;
//echo '<pre>';
//var_dump($_POST) ;
//var_dump($_COOKIE) ;
//var_dump($_SESSION) ;
//echo '</pre>';

$user = new Models_User ;
if (isset ($_POST['in']))
{
    $user->authUser($_POST['login'], $_POST['pass']) ;
   
} elseif(!isset ($_COOKIE['ID'])) {
    $user->isAuth();
} elseif(isset ($_POST['out'])) {
    $user->out();
    header("Location: /$db->path") ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title></title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<link rel="stylesheet" href="/<?php echo $db->path ; ?>style.css" type="text/css" media="screen, projection" />
        <script type="text/javascript" src="/<?php echo $db->path ; ?>public/js/prototype.js"></script>
        <script type="text/javascript" src="/<?php echo $db->path ; ?>public/js/scriptaculous.js?load=effects,builder"></script>
        <script type="text/javascript" src="/<?php echo $db->path ; ?>public/js/lightbox.js"></script>
        <link rel="stylesheet" href="/<?php echo $db->path ; ?>public/css/lightbox.css" type="text/css" media="screen" />
        <!-- TinyMCE -->
        <script type="text/javascript" src="/<?php echo $db->path ; ?>public/js/tiny_mce/tiny_mce.js"></script>
        <script type="text/javascript">
                tinyMCE.init({
                        mode : "textareas",
                        theme : "simple"
                });
        </script>
        <!-- /TinyMCE -->
</head>

<body>

<div id="top">
    <?php
    require_once 'app/views/top.php';
    ?>
</div>

<div id="wrapper">

	<div id="header">
            <div id="info">
                <ul id="infomenu">
                    <li><a href="/<?php echo $db->path ; ?>">Home</a></li>
                    <li><a href="/<?php echo $db->path ; ?>delivery">Delivery</a></li>
                    <li><a href="/<?php echo $db->path ; ?>pay">Pay</a></li>
                    <li><a href="/<?php echo $db->path ; ?>about">About</a></li>
                    <li><a href="/<?php echo $db->path ; ?>contact">Contact</a></li>
                </ul>
            </div>
            <div id="logo"></div>
	</div><!-- #header-->

	<div id="middle">

		<div id="container">
			<div id="content">
				<div class="titlebar">Content</div>
<?php
$router->delegate();     
?>
</div><!-- #content-->
		</div><!-- #container-->

		<div class="sidebar" id="sideLeft">
			<div class="titlebar">Menu</div>

                        <?php 

                            require_once 'app/views/menu.php' ;

                        ?>

                </div><!-- .sidebar#sideLeft -->

		<div class="sidebar" id="sideRight">
			<div class="titlebar">Top-3</div>
			<?php 

                                require_once 'app/views/side.php' ;

                        ?>
		</div><!-- .sidebar#sideRight -->

	</div><!-- #middle-->

</div><!-- #wrapper -->

<div id="footer">
	<b><p>made by <u>Dmitry Yermolayev</u></p><p> mailto:dmitryy90@gmail.com</p></b>
</div><!-- #footer -->

</body>
</html>
